import Vue from 'vue';
import Router from 'vue-router';
Vue.use(Router);
// Layout
import Layout from '@/views/layout/index';
import echart from './modules/echart';
export const constantRoutes = [
  {
    path: '/404',
    component: () => import('@/views/errorPage/404')
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401')
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        meta: {
          title: 'demo'
        },
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index.vue')
      }
    ]
  },
  {
    path: '/echart',
    component: Layout,
    children: echart,
    meta: {
      isShow: false
    }
  },
  {
    path: '/demo',
    component: Layout,
    name: 'Demo',
    children: [
      {
        path: 'changeTheme',
        meta: {
          title: '主题换肤'
        },
        name: 'Loading',
        component: () => import('@/views/demo/changeTheme.vue')
      },
      {
        path: 'bigFile',
        meta: {
          title: '文件切片上传'
        },
        name: 'bigFile',
        component: () => import('@/views/demo/bigFile.vue')
      },
      {
        path: 'iconfont',
        meta: {
          title: '图标字体'
        },
        name: 'CountDown',
        component: () => import('@/views/demo/iconfont.vue')
      },
      {
        path: 'watermark',
        meta: {
          title: '添加水印'
        },
        name: 'Sticky',
        component: () => import('@/views/demo/watermark.vue')
      },
      {
        path: 'fileUpload',
        meta: {
          title: '文件上传'
        },
        name: 'fileUpload',
        component: () => import('@/views/demo/imgUpload.vue')
      },
      {
        path: 'imgPreview',
        meta: {
          title: '图片预览'
        },
        name: 'imgPreview',
        component: () => import('@/views/demo/imgPreview.vue')
      },
      {
        path: 'pullDownLoading',
        meta: {
          title: '上拉加载更多'
        },
        name: 'pullDownLoading',
        component: () => import('@/views/demo/pullDownLoading.vue')
      },
      {
        path: 'directive',
        meta: {
          title: '自定义指令'
        },
        name: 'directive',
        component: () => import('@/views/demo/directive.vue')
      },
      {
        path: 'loading',
        meta: {
          title: '测试加载占位(可替换加载图片)'
        },
        name: 'loading',
        component: () => import('@/views/demo/loading.vue')
      },
      {
        path: 'print',
        meta: {
          title: '在线打印(区分打印和非打印区域)'
        },
        name: 'print',
        component: () => import('@/views/demo/print.vue')
      },
      {
        path: 'signatureOnLine',
        meta: {
          title: '在线电子签名'
        },
        name: 'signatureOnLine',
        component: () => import('@/views/demo/signatureOnLine.vue')
      },
      {
        path: 'video',
        meta: {
          title: '视频播放'
        },
        name: 'video',
        component: () => import('@/views/demo/video.vue')
      },
      {
        path: 'draggable',
        meta: {
          title: '拖拽组件'
        },
        name: 'draggable',
        component: () => import('@/views/demo/draggable.vue')
      },
      {
        path: 'map',
        meta: {
          title: '高德地图(进行中)'
        },
        name: 'map',
        component: () => import('@/views/demo/map.vue')
      }
    ]
  },
  {
    path: '*',
    redirect: '/404'
  }
];

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  });
const router = createRouter();

export default router;
